#ifndef FOLDERSTRUCTSCAN_H
#define FOLDERSTRUCTSCAN_H

#include "headfile.h"
#include "traversepath.h"


class FolderStructScan : public QMainWindow
{
	Q_OBJECT

public:
	FolderStructScan(QWidget *parent = 0, Qt::WFlags flags = 0);
	//

	~FolderStructScan();

	void appendStandardItem(QStandardItem *root,std::map< std::string,std::vector<std::string> >);
	void scanXmlChild(const QModelIndex &index);
	void scanFolderChild(const QModelIndex &index);
	void loadStructFile(QString xmlpath,QString folderpath);
	void init_cmbitem();
	void traverseItem(QStandardItem *root);
	void updateParent(QStandardItem *root);
	QStandardItemModel *StructFileToModel(TiXmlNode *xml_node,QString folderpath);
	QStandardItem *XML_SiblingToItem(TiXmlNode *root_node,QString folderpathbool,bool checkExists = true);
	QList<QStandardItem *> *scanXmlSibling(TiXmlNode *root_node,QString folderpath);

private slots:

	//// App

	//// Menu
	//bool onMenuLoadStruct(QString path);
	//bool onMenuStructSaveAs(QString path);

	int onMenuTraversePathStruct();
	void onMenuLoadStructFile();
	//void onMenuSetActCity(QString path);
	//void onMenuOpenOption();
	//void onMenuAboutApp();

	//// Widget
	void selectDirPath();
	void drawTree(std::map< std::string,std::vector<std::string> >);
	
	//bool startTask();
	//void chkRelationXML_click();

	//cmb
	void cmbItemChanged(int index);

	//func
	void QTreeViewCheckEvent(QStandardItem *root);
	void quitApp();
	void expandedChild(const QModelIndex &index);

private:
	Ui::FolderStructScanClass ui;

	// class attr
	bool userCheckBoxSignal;
	enum StructAttr {Name,Path,State};
	enum StructFlag {Dir_Struct,XML_Struct};
	
	QIcon folderIcon;
	StructFlag nowFlag;
	QStandardItemModel *model;
	QFileIconProvider iconProvider;

	TiXmlDocument *doc;


	
};

#endif // FOLDERSTRUCTSCAN_H
